using System.Collections;
using Since.Netcode;
using SinceUnity.LobbyNetwork;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;

public class BattleLevel : MonoBehaviour
{
	public int Num = 1;
	public int CurNum = 0;
	public int MaxNum = 250;
	public float duration = 0.3f;



	void Awake()
	{
		StartCoroutine(CreateEnemy());
	}

	IEnumerator CreateEnemy()
	{
		while (true)
		{
			if (CurNum >= MaxNum)
			{
				yield return null;
				continue;
			}


			for (int i = 0; i < Num; i++)
			{
				if (CurNum >= MaxNum)
					break;
				var position = new Vector3(Random.Range(-10, 10), 40, 0);
				var player = SinceUnity.LobbyNetwork.NetworkPlayer.Local;
				if (player != null)
				{
					player.SpawnServerRpc("Enemy", position);
					CurNum++;
				}
			}

			yield return new WaitForSeconds(duration);
		}
	}
}
